package com.lingying.caiwudailikehudaun.mapper.renYuanXinXi;

import com.lingying.caiwudailikehudaun.domain.renYuanXinXi.RenYuanXinXiBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface RenYuanXinXiMapper {


    /**
     * 查询人员信息表数据，如果字段不为空进行模糊搜索
     * @param yuanGongName
     * @param zhengJianHao
     * @param yuanGongPhone
     * @param yuanGongBuMen
     * @param renYuanZhuangTai
     * @param yuanGongBeginMoney
     * @param yuanGongEndMoney
     * @param congYeBeginTime
     * @param congYeEndTime
     * @param liZhiBeginTime
     * @param liZhiEndTime
     * @param shiFouZuoZhang
     * @param shiFouShenBao
     * @param zuoZhangShenBaoId
     * @param pages
     * @param limit
     * @return
     */
    @Select("<script>" +
            "select * from renYuanXinXi where zuoZhangShenBaoId=#{zuoZhangShenBaoId} and xianShiZhuangTai=0" +
            "<if test=\"yuanGongName !=null and yuanGongName != ''\"> " +
            " and xingMing=#{yuanGongName}" +
            "</if>"+
            "<if test=\"zhengJianHao !=null and zhengJianHao != ''\"> " +
            " and zhengZhaoHaoMa=#{zhengJianHao}" +
            "</if>"+
            "<if test =\" yuanGongPhone != null and yuanGongPhone != '' \"> " +
            " and tel = #{yuanGongPhone} " +
            "</if>" +
            "<if test =\" yuanGongBuMen != null \"> " +
            " and yuanGongBuMen = #{yuanGongBuMen} " +
            "</if>" +
            "<if test =\" renYuanZhuangTai != null \"> " +
            " and renYuanZhuangTai = #{renYuanZhuangTai} " +
            "</if>" +
            "<if test =\" yuanGongBeginMoney != null and yuanGongBeginMoney != ''\"> " +
            " and yuanGongGongZi &gt;= #{yuanGongBeginMoney} " +
            "</if>" +
            "<if test=\" yuanGongEndMoney != null and yuanGongEndMoney != ''\">" +
            " and yuanGongGongZi &lt;= #{yuanGongEndMoney}  " +
            "</if>" +
            "<if test=\" yuanGongBeginMoney != null and yuanGongBeginMoney != '' and yuanGongEndMoney != null and yuanGongEndMoney != ''\">" +
            " and #{yuanGongBeginMoney} &lt;= yuanGongGongZi &lt;= #{yuanGongEndMoney}  " +
            "</if>" +
            "<if test =\" congYeBeginTime != null and congYeBeginTime != ''\"> " +
            " and congYeRiQi &gt;= #{congYeBeginTime} " +
            "</if>" +
            "<if test=\" congYeEndTime != null and congYeEndTime != ''\">" +
            " and congYeRiQi &lt;= #{congYeEndTime} " +
            "</if>" +
            "<if test=\" congYeBeginTime != null and congYeBeginTime != '' and congYeEndTime != null and congYeEndTime != ''\">" +
            " and #{congYeBeginTime} &lt;= congYeRiQi &lt;= #{congYeEndTime} " +
            "</if>" +
            "<if test =\" liZhiBeginTime != null and liZhiBeginTime != ''\"> " +
            " and liZhiTime &gt;= #{liZhiBeginTime} " +
            "</if>" +
            "<if test=\" liZhiEndTime != null and liZhiEndTime != ''\">" +
            " and liZhiTime &lt;= #{liZhiEndTime} " +
            "</if>" +
            "<if test=\" liZhiBeginTime != null and liZhiBeginTime != '' and liZhiEndTime != null and liZhiEndTime != ''\">" +
            " and #{liZhiBeginTime} &lt;= liZhiTime &lt;= #{liZhiEndTime} " +
            "</if>" +
            "<if test=\" shiFouZuoZhang != null \">" +
            " and isZuoZhang = #{shiFouZuoZhang} " +
            "</if>" +
            "<if test=\" shiFouShenBao != null \">" +
            " and isShenBao = #{shiFouShenBao} " +
            "</if>" +
            " limit #{pages},#{limit}" +
            "</script>")
    List<RenYuanXinXiBean> queryUserBean(String yuanGongName, String zhengJianHao, String yuanGongPhone, Integer yuanGongBuMen, Integer renYuanZhuangTai, Integer yuanGongBeginMoney, Integer yuanGongEndMoney, String congYeBeginTime, String congYeEndTime, String liZhiBeginTime, String liZhiEndTime, Integer shiFouZuoZhang, Integer shiFouShenBao, Integer zuoZhangShenBaoId, Integer pages, Integer limit);


    /**
     * 查询人员信息表数据当前搜索条件下的总条数，用于分页
     * @param yuanGongName
     * @param zhengJianHao
     * @param yuanGongPhone
     * @param yuanGongBuMen
     * @param renYuanZhuangTai
     * @param yuanGongBeginMoney
     * @param yuanGongEndMoney
     * @param congYeBeginTime
     * @param congYeEndTime
     * @param liZhiBeginTime
     * @param liZhiEndTime
     * @param shiFouZuoZhang
     * @param zuoZhangShenBaoId
     * @return
     */
    @Select("<script>" +
            "select count(*) from renYuanXinXi where zuoZhangShenBaoId=#{zuoZhangShenBaoId} and xianShiZhuangTai=0" +
            "<if test=\"yuanGongName !=null and yuanGongName != ''\"> " +
            " and xingMing=#{yuanGongName}" +
            "</if>"+
            "<if test=\"zhengJianHao !=null and zhengJianHao != ''\"> " +
            " and zhengZhaoHaoMa=#{zhengJianHao}" +
            "</if>"+
            "<if test =\" yuanGongPhone != null and yuanGongPhone != '' \"> " +
            " and tel = #{yuanGongPhone} " +
            "</if>" +
            "<if test =\" yuanGongBuMen != null \"> " +
            " and yuanGongBuMen = #{yuanGongBuMen} " +
            "</if>" +
            "<if test =\" renYuanZhuangTai != null \"> " +
            " and renYuanZhuangTai = #{renYuanZhuangTai} " +
            "</if>" +
            "<if test =\" yuanGongBeginMoney != null and yuanGongBeginMoney != ''\"> " +
            " and yuanGongGongZi &gt;= #{yuanGongBeginMoney} " +
            "</if>" +
            "<if test=\" yuanGongEndMoney != null and yuanGongEndMoney != ''\">" +
            " and yuanGongGongZi &lt;= #{yuanGongEndMoney}  " +
            "</if>" +
            "<if test=\" yuanGongBeginMoney != null and yuanGongBeginMoney != '' and yuanGongEndMoney != null and yuanGongEndMoney != ''\">" +
            " and #{yuanGongBeginMoney} &lt;= yuanGongGongZi &lt;= #{yuanGongEndMoney}  " +
            "</if>" +
            "<if test =\" congYeBeginTime != null and congYeBeginTime != ''\"> " +
            " and congYeRiQi &gt;= #{congYeBeginTime} " +
            "</if>" +
            "<if test=\" congYeEndTime != null and congYeEndTime != ''\">" +
            " and congYeRiQi &lt;= #{congYeEndTime} " +
            "</if>" +
            "<if test=\" congYeBeginTime != null and congYeBeginTime != '' and congYeEndTime != null and congYeEndTime != ''\">" +
            " and #{congYeBeginTime} &lt;= congYeRiQi &lt;= #{congYeEndTime} " +
            "</if>" +
            "<if test =\" liZhiBeginTime != null and liZhiBeginTime != ''\"> " +
            " and liZhiTime &gt;= #{liZhiBeginTime} " +
            "</if>" +
            "<if test=\" liZhiEndTime != null and liZhiEndTime != ''\">" +
            " and liZhiTime &lt;= #{liZhiEndTime} " +
            "</if>" +
            "<if test=\" liZhiBeginTime != null and liZhiBeginTime != '' and liZhiEndTime != null and liZhiEndTime != ''\">" +
            " and #{liZhiBeginTime} &lt;= liZhiTime &lt;= #{liZhiEndTime} " +
            "</if>" +
            "<if test=\" shiFouZuoZhang != null \">" +
            " and isZuoZhang = #{shiFouZuoZhang} " +
            "</if>" +
            "<if test=\" shiFouShenBao != null \">" +
            " and isShenBao = #{shiFouShenBao} " +
            "</if>" +
            "</script>")
    Integer queryUserBeanCount(String yuanGongName, String zhengJianHao, String yuanGongPhone, Integer yuanGongBuMen, Integer renYuanZhuangTai, Integer yuanGongBeginMoney, Integer yuanGongEndMoney, String congYeBeginTime, String congYeEndTime, String liZhiBeginTime, String liZhiEndTime, Integer shiFouZuoZhang, Integer shiFouShenBao, Integer zuoZhangShenBaoId);

    /**
     * 查询人员信息做下拉框回显
     * 桑满  20210428
     */
    @Select("SELECT xingMing,zhengZhaoHaoMa,tel FROM renYuanXinXi WHERE zuoZhangShenBaoId = #{zuoZhangShenBaoId} AND xianShiZhuangTai = 0")
    List<RenYuanXinXiBean> queryYuanGongXinXi(Integer zuoZhangShenBaoId);

}
